﻿using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace CloudShot.Utils
{
	internal static class ErrorsHelper
	{
		public static void ShowError(Exception err)
		{
			string message = GetErrorMessage(err);
			MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
			Trace.TraceError("Message: " + message);
		}

		public static void TraceError(Exception err)
		{
			Trace.TraceError("Message: " + GetErrorMessage(err));
		}

		private static string GetErrorMessage(Exception err)
		{
			return string.Format("{0}\r\nType: {1}\r\nDate: {2}\r\nStackTrace: {3}", err.Message, err.GetType().FullName, DateTime.Now, err.StackTrace);
		}
	}
}